<?php
class m_pekerjaan extends Model{
    var $table = 'pekerjaan';
    
    function getListPekerjaan(){
        $query = $this->db->query('select * from pekerjaan');
        if($query->num_rows() > 0){
            $result = $query->result_array();
        }else $result = array();
        
        return $result;
    }
    function getPekerjaanById($id = NULL){
        if($id != NULL){
            $where = "where id='$id'";
        }else $where = "";
        
        $query = $this->db->query("select * from pekerjaan $where");
        if($query->num_rows() > 0){
            $result = $query->result_array();
        }else $result = array();
        
        return $result;
    }
    function addPekerjaan($data){
        $insert = $this->db->insert($this->table,$data);
        if(!$insert){
            $return = FALSE;
        }else $return = TRUE;
        return $return;
    }
    function editPekerjaan($data){
        $this->db->where('id',$data['id']);
        $update = $this->db->update($this->table,$data);
        if(!$update){
            $return = FALSE;
        }else $return = TRUE;
        return $return;
    }
    function deletePekerjaan($id){
        $delete = $this->db->delete($this->table,array('id'=>$id));
        if(!$delete){
            $return = FALSE;
        }else $return = TRUE;
        return $return;
    }
}
?>
